import 'package:flutter/material.dart';

class UiLinearGradientMask extends StatelessWidget {
  const UiLinearGradientMask({
    super.key,
    required this.child,
    this.gradient = true,
    this.colors,
    this.stops,
    this.tileMode = TileMode.mirror,
    this.begin = Alignment.centerLeft,
    this.end = Alignment.centerRight,
    this.transform,
  });
  final Widget child;
  final bool gradient;
  final AlignmentGeometry begin;
  final AlignmentGeometry end;
  final List<Color>? colors;
  final List<double>? stops;
  final TileMode tileMode;
  final GradientTransform? transform;

  @override
  Widget build(BuildContext context) {
    return gradient
        ? ShaderMask(
            shaderCallback: (bounds) {
              return LinearGradient(
                begin: begin,
                end: end,
                colors: colors ??
                    const [
                      Color.fromARGB(255, 4, 209, 250),
                      Color.fromARGB(255, 3, 48, 249),
                    ],
                stops: stops,
                tileMode: tileMode,
                transform: transform,
              ).createShader(bounds);
            },
            child: child,
          )
        : child;
  }
}
